package wowmobile;

public class Monster {
    private int id, maxhp, maxmana, speed, attack, defence, hp, mana, level, image;
    private String name;
   // List<Magic> magiclist;
    Threat threat;


    Monster(int id, String name, int level, int maxhp, int maxmana, int speed, int attack, int defence, int image) {

        this.id = id;
        this.name=name;
        this.level = level;
        this.maxhp = maxhp;
        this.maxmana = maxmana;
        this.hp = maxhp;
        this.mana = maxmana;
        this.speed = speed;
        this.attack = attack;
        this.defence = defence;
        //this.magiclist = new ArrayList<Magic>(magiclist);
        this.image = image;
    }
    
    Monster(Monster monster) {
        this.id = monster.getId();
        this.name = monster.getName();
        this.level = monster.getLevel();
        this.maxhp = monster.getMaxhp();
        this.maxmana = monster.getMaxmana();
        this.hp = monster.getMaxhp();
        this.mana = monster.getMaxmana();
        this.speed = monster.getSpeed();
        this.attack = monster.getAttack();
        this.defence = monster.getDefence();
        //this.magiclist = new ArrayList<Magic>(monster.getMagiclist());
        this.image = monster.getImage();
    }

    public void statChange(int hp, int mana, int defence, int attack, int speed, int level) {
        changeHP(hp, level);
        changeMana(mana);
        this.defence += (int)((double)defence * (double)((double)level / (double)this.level));
        this.attack += (int)((double)attack * (double)((double)level / (double)this.level));
        this.speed += (int)((double)speed * (double)((double)level / (double)this.level));
    }
    
    //dodatnie amount zabiera życie, ujemne dodaje
    public void changeHP(int amount, int level) {
        if (amount < 0) {
            if (this.hp - amount <= this.maxhp) {
                this.hp -= amount;
            } else {
                this.hp = this.maxhp;
            }
        }
        else {
            if ((int)((double)this.hp - (double)amount/(double)this.defence) >= 0) {
                this.hp -= (int)((double)amount * (double)((double)level / (double)this.level) / (double)defence);
            } else {
                this.hp = 0;
            }
        }
    }
    
    public void changeMana(int amount) {
        if (amount < 0) {
            if (mana - amount <= maxmana) {
                mana -= amount;
            } else {
                mana = maxmana;
            }
        }
        else {
            if (mana - amount >= 0) {
                mana -= amount;
            } else {
                mana = 0;
            }
        }
    }

    public int getImage() {
        return image;
    }

    public String getName() {
        return name;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }
    
    /*public List<Magic> getMagiclist() {
        return magiclist;
    }*/

    public Threat getThreat() {
        return threat;
    }

    public void setMana(int mana) {
        this.mana = mana;
    }

    public void setMaxhp(int maxhp) {
        this.maxhp = maxhp;
    }

    public void setMaxmana(int maxmana) {
        this.maxmana = maxmana;
    }

    public void setThreat(Threat threat) {
        this.threat = threat;
    }

    public int getMana() {
        return mana;
    }

    public int getMaxhp() {
        return maxhp;
    }

    public int getMaxmana() {
        return maxmana;
    }

    public int getAttack() {
        return attack;
    }

    public int getDefence() {
        return defence;
    }

    public int getHp() {
        return hp;
    }

    public int getId() {
        return id;
    }

    public int getSpeed() {
        return speed;
    }

    public void setAttack(int attack) {
        this.attack = attack;
    }

    public void setDefence(int defence) {
        this.defence = defence;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
}
